<?xml version="1.0" encoding="UTF-8"?>
<!--
  Created by IntelliJ IDEA.
  User: azim
  Date: 5/23/13
  Time: 10:31 AM
-->
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="templates/template.xhtml">

    <ui:define name="title">Category View Page</ui:define>

    <ui:define name="left">

        <p:menuitem value="Edit Profile" ajax="false" action="#{userController.UserProfileForm}"/>
        <p:menuitem value="View Profile" ajax="false" action="#{userController.showUserDetails(null)}"/>

    </ui:define>

    <ui:define name="cbody">

        <div style="padding: 20px;">

            <h2>My Profile</h2>

            <div>

                <h:form enctype="multipart/form-data">

                    <h:panelGrid columns="3" cellspacing="10">

                        <h:outputLabel for="firstname" value="First Name : "/>
                        <p:inputText id="firstname"
                                     value="#{userController.userProfile.firstName}"
                                     required="true"
                                     requiredMessage="Error : First Name is required"/>
                        <p:message for="firstname" styleClass="error"/>

                        <h:outputLabel for="lastname" value="Last Name : "/>
                        <p:inputText id="lastname"
                                     value="#{userController.userProfile.lastName}"
                                     required="true"
                                     requiredMessage="Error : Last Name is required"/>
                        <p:message for="lastname" styleClass="error"/>

                        <h:outputLabel for="email" value="Email : "/>
                        <p:inputText id="email"
                                     value="#{userController.user.email}"
                                     required="true"
                                     requiredMessage="Error : Email Id is required"/>
                        <p:message for="email" styleClass="error"/>

                        <h:outputLabel for="contact" value="Contact No : "/>
                        <p:inputText id="contact"
                                     value="#{userController.userProfile.contactNo}"
                                     required="true"
                                     requiredMessage="Error : Contact No. is required"/>
                        <p:message for="contact" styleClass="error"/>

                        <h:outputLabel for="address" value="Address : "/>
                        <p:inputTextarea id="address"
                                         rows="3"
                                         cols="50"
                                         value="#{userController.userProfile.address}"/>
                        <p:message for="address" styleClass="error"/>

                        <p:outputLabel styleClass="label" for="imageFile" value="Profile Picture : "/>
                        <p:fileUpload id="imageFile"
                                      value="#{userController.uploadedPhoto}"
                                      mode="simple"
                                      allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
                        <p:message for="imageFile" styleClass="error"/>

                    </h:panelGrid>

                    <p:commandButton value="Update profile" ajax="false" action="#{userController.updateProfile}"/>

                </h:form>

                <p:messages globalOnly="true"/>

            </div>

        </div>

    </ui:define>
</ui:composition>

</html>